package com.welsy.classroom.command
{
	import com.adobe.cairngorm.control.CairngormEvent;
	import flash.events.Event;
	import mx.controls.Alert;
	import mx.collections.ArrayCollection;
	import mx.rpc.IResponder;
	import mx.rpc.events.ResultEvent;
	import com.adobe.cairngorm.commands.ICommand;
	import com.welsy.util.NamespaceLocator;
	import com.welsy.classroom.model.ClassModelLocator;
	import com.welsy.usermgt.vo.UserVO;
	import com.welsy.classroom.business.AddNewsDelegate;
	import com.welsy.qnames.DataTypes;
	import com.welsy.classroom.event.AddNewsEvent;
	import com.welsy.newsmgt.model.NewsMgtModelLocator;
	
	public class AddNewsCommand implements ICommand, IResponder
	{
		
		public function execute(event : CairngormEvent):void {
			var delegate : AddNewsDelegate = new AddNewsDelegate(this);
			var an : AddNewsEvent = AddNewsEvent(event);

			delegate.addNews(an.newsId, an.title, an.descr, an.creationDate, an.authorId, an.classIds);
		}
		
		public function result( event : Object) : void {
			var xres :XMLList = XMLList(event.result)
						
			//xres.descendants(DataTypes.TAG_ADDNEWSRESULT).child(DataTypes.TAG_RETURNVALUE) == "true")
			NewsMgtModelLocator.getInstance().newsList = null
		}
		
		public function fault( event : Object ) : void {
			Alert.show("AddNewsCommand.fault!");
		}
	}
}